home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / xmcd-1.4 / libdi.d / os_svr4.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-10  |  6.7 KB  |  247 lines

  1. /*
  2.  *   libdi - CD Audio Player Device Interface Library
  3.  *
  4.  *   Copyright (C) 1995  Ti Kan
  5.  *   E-mail: ti@amb.org
  6.  *
  7.  *   This program is free software; you can redistribute it and/or modify
  8.  *   it under the terms of the GNU General Public License as published by
  9.  *   the Free Software Foundation; either version 2 of the License, or
  10.  *   (at your option) any later version.
  11.  *
  12.  *   This program is distributed in the hope that it will be useful,
  13.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  *   GNU General Public License for more details.
  16.  *
  17.  *   You should have received a copy of the GNU General Public License
  18.  *   along with this program; if not, write to the Free Software
  19.  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  */
  21. #ifndef __OS_SVR4_H__
  22. #define __OS_SVR4_H__
  23.  
  24. #if defined(SVR4) && !defined(sun) && defined(DI_SCSIPT) && !defined(DEMO_ONLY)
  25.  
  26. #ifndef LINT
  27. static char *_os_svr4_h_ident_ = "@(#)os_svr4.h    5.4 94/12/28";
  28. #endif
  29.  
  30. #if defined(i386) || (defined(_FTX) && defined(__hppa))
  31. /*
  32.  *   USL UNIX SVR4/x86 support
  33.  *   Stratus UNIX SVR4/PA-RISC FTX 3.x support
  34.  *   Portable Device Interface/SCSI Device Interface
  35.  *
  36.  *   This software fragment contains code that interfaces the
  37.  *   CD player application to the UNIX System V Release 4
  38.  *   operating system for the Intel x86 hardware platforms and
  39.  *   Stratus PA-RISC systems.  The name "USL", "UNIX", "Intel",
  40.  *   "Stratus" and "PA-RISC" are used here for identification
  41.  *   purposes only.
  42.  */
  43.  
  44. #include <sys/scsi.h>
  45. #include <sys/sdi_edt.h>
  46. #include <sys/sdi.h>
  47.  
  48.  
  49. #define OS_MODULE    /* Indicate that this is compiled on a supported OS */
  50. #define SETUID_ROOT    /* Setuid root privilege is required */
  51.  
  52.  
  53. #ifndef SCL_AD
  54.  
  55. /* SCSI 12-byte CDB */
  56. #define SCL_AD(x)    ((byte_t *) (x) + 2)
  57. #define SCL_SZ        12
  58.  
  59. struct scl {
  60.     unsigned int    sl_pad0:16;    /* pad for alignment */
  61.     unsigned int    sl_op:8;    /* Opcode */
  62.     unsigned int    sl_res1:5;    /* Reserved field */
  63.     unsigned int    sl_lun:3;    /* Logical unit number */
  64.  
  65.     word32_t    sl_addr;    /* Block address */
  66.     word32_t    sl_len;        /* Transfer length */
  67.  
  68.     byte_t        sl_res2;    /* Reserved field */
  69.     byte_t        sl_cont;    /* Control byte */
  70. };
  71.  
  72. #endif    /* SCL_AD */
  73.  
  74.  
  75. /* SCSI Command Descriptor Block union */
  76. union scsi_cdb {
  77.     struct scs    scs;
  78.     struct scm    scm;
  79.     struct scl    scl;
  80. };
  81.  
  82.  
  83. /* Macros to update various fields of the SCSI CDB structures.
  84.  * These are used to work around byte alignment restrictions and
  85.  * padding with some compilers.  In general, define NO_ALIGN_LIMIT
  86.  * if and only if you are sure that the compiler will not insert
  87.  * pad bytes between any field of the SCSI CDB structure.
  88.  */
  89.  
  90. #ifdef NO_ALIGN_LIMIT
  91.  
  92. #define CDB6_BLK(a,d)    (a)->ss_addr = (d)
  93. #define CDB6_LEN(a,d)    (a)->ss_len = (d)
  94. #define CDB6_CTL(a,d)    (a)->ss_cont = (d)
  95. #define CDB10_BLK(a,d)    (a)->sm_addr = (d)
  96. #define CDB10_LEN(a,d)    (a)->sm_len = (d)
  97. #define CDB10_RSV(a,d)    (a)->sm_res2 = (d)
  98. #define CDB10_CTL(a,d)    (a)->sm_cont = (d)
  99. #define CDB12_BLK(a,d)    (a)->sl_addr = (d)
  100. #define CDB12_LEN(a,d)    (a)->sl_len = (d)
  101. #define CDB12_RSV(a,d)    (a)->sl_res2 = (d)
  102. #define CDB12_CTL(a,d)    (a)->sl_cont = (d)
  103.  
  104. #else    /* !NO_ALIGN_LIMIT */
  105.  
  106. #if _BYTE_ORDER_ == _L_ENDIAN_
  107.  
  108. #define CDB6_BLK(a,d)    {                    \
  109.     register word16_t *p = (word16_t *)(void *) SCS_AD(a);    \
  110.     p[1] = (d);                        \
  111. }
  112. #define CDB6_LEN(a,d)    {                    \
  113.     register byte_t *p = (byte_t *) SCS_AD(a);        \
  114.     p[4] = (d);                        \
  115. }
  116. #define CDB6_CTL(a,d)    {                    \
  117.     register byte_t *p = (byte_t *) SCS_AD(a);        \
  118.     p[5] = (d);                        \
  119. }
  120. #define CDB10_BLK(a,d)    {                    \
  121.     register word16_t *p = (word16_t *)(void *) SCM_AD(a);    \
  122.     p[1] = (word16_t) (d);                    \
  123.     p[2] = (word16_t) ((d) >> 16);                \
  124. }
  125. #define CDB10_LEN(a,d)    {                    \
  126.     register byte_t *p = (byte_t *) SCM_AD(a);        \
  127.     p[7] = (byte_t) (d);                    \
  128.     p[8] = (byte_t) ((d) >> 8);                \
  129. }
  130. #define CDB10_RSV(a,d)    {                    \
  131.     register byte_t *p = (byte_t *) SCM_AD(a);        \
  132.     p[6] = (d);                        \
  133. }
  134. #define CDB10_CTL(a,d)    {                    \
  135.     register byte_t *p = (byte_t *) SCM_AD(a);        \
  136.     p[9] = (d);                        \
  137. }
  138. #define CDB12_BLK(a,d)    {                    \
  139.     register word16_t *p = (word16_t *)(void *) SCL_AD(a);    \
  140.     p[1] = (word16_t) (d);                    \
  141.     p[2] = (word16_t) ((d) >> 16);                \
  142. }
  143. #define CDB12_LEN(a,d)    {                    \
  144.     register word16_t *p = (word16_t *)(void *) SCL_AD(a);    \
  145.     p[3] = (word16_t) (d);                    \
  146.     p[4] = (word16_t) ((d) >> 16);                \
  147. }
  148. #define CDB12_RSV(a,d)    {                    \
  149.     register byte_t *p = (byte_t *) SCL_AD(a);        \
  150.     p[10] = (d);                        \
  151. }
  152. #define CDB12_CTL(a,d)    {                    \
  153.     register byte_t *p = (byte_t *) SCL_AD(a);        \
  154.     p[11] = (d);                        \
  155. }
  156.  
  157. #else    /* _BYTE_ORDER_ */
  158.  
  159. #define CDB6_BLK(a,d)    {                    \
  160.     register word16_t *p = (word16_t *)(void *) SCS_AD(a);    \
  161.     p[1] = (d);                        \
  162. }
  163. #define CDB6_LEN(a,d)    {                    \
  164.     register byte_t *p = (byte_t *) SCS_AD(a);        \
  165.     p[4] = (d);                        \
  166. }
  167. #define CDB6_CTL(a,d)    {                    \
  168.     register byte_t *p = (byte_t *) SCS_AD(a);        \
  169.     p[5] = (d);                        \
  170. }
  171. #define CDB10_BLK(a,d)    {                    \
  172.     register word16_t *p = (word16_t *)(void *) SCM_AD(a);    \
  173.     p[1] = (word16_t) ((d) >> 16);                \
  174.     p[2] = (word16_t) (d);                    \
  175. }
  176. #define CDB10_LEN(a,d)    {                    \
  177.     register byte_t *p = (byte_t *) SCM_AD(a);        \
  178.     p[7] = (byte_t) ((d) >> 8);                \
  179.     p[8] = (byte_t) (d);                    \
  180. }
  181. #define CDB10_RSV(a,d)    {                    \
  182.     register byte_t *p = (byte_t *) SCM_AD(a);        \
  183.     p[6] = (d);                        \
  184. }
  185. #define CDB10_CTL(a,d)    {                    \
  186.     register byte_t *p = (byte_t *) SCM_AD(a);        \
  187.     p[9] = (d);                        \
  188. }
  189. #define CDB12_BLK(a,d)    {                    \
  190.     register word16_t *p = (word16_t *)(void *) SCL_AD(a);    \
  191.     p[1] = (word16_t) ((d) >> 16);                \
  192.     p[2] = (word16_t) (d);                    \
  193. }
  194. #define CDB12_LEN(a,d)    {                    \
  195.     register word16_t *p = (word16_t *)(void *) SCL_AD(a);    \
  196.     p[3] = (word16_t) ((d) >> 16);                \
  197.     p[4] = (word16_t) (d);                    \
  198. }
  199. #define CDB12_RSV(a,d)    {                    \
  200.     register byte_t *p = (byte_t *) SCL_AD(a);        \
  201.     p[10] = (d);                        \
  202. }
  203. #define CDB12_CTL(a,d)    {                    \
  204.     register byte_t *p = (byte_t *) SCL_AD(a);        \
  205.     p[11] = (d);                        \
  206. }
  207.  
  208. #endif    /* _BYTE_ORDER_ */
  209.  
  210. #endif    /* !NO_ALIGN_LIMIT */
  211.  
  212. #endif    /* i386 _FTX __hppa */
  213.  
  214.  
  215. #ifdef MOTOROLA
  216. /*
  217.  *   Motorola 88k UNIX SVR4 support
  218.  *
  219.  *   This software fragment contains code that interfaces the CD
  220.  *   player application to the System V Release 4 operating system
  221.  *   from Motorola.  The name "Motorola" is used here for identification
  222.  *   purposes only.
  223.  */
  224.  
  225. #include <sys/param.h>
  226. #include <sys/dk.h>
  227.  
  228.  
  229. #define OS_MODULE    /* Indicate that this is compiled on a supported OS */
  230. #define SETUID_ROOT    /* Setuid root privilege is required */
  231.  
  232.  
  233. #endif    /* MOTOROLA */
  234.  
  235.  
  236. /* Public function prototypes */
  237. extern bool_t    pthru_send(byte_t, word32_t, byte_t *, word32_t, byte_t,
  238.             word32_t, byte_t, byte_t, byte_t, bool_t);
  239. extern bool_t    pthru_open(char *);
  240. extern void    pthru_close(void);
  241. extern char    *pthru_vers(void);
  242.  
  243. #endif    /* SVR4 sun DI_SCSIPT DEMO_ONLY */
  244.  
  245. #endif    /* __OS_SVR4_H__ */
  246.  
  247.